#ifndef RENDEROBJECT_H_
#define RENDEROBJECT_H_

#include "declareinc.h"
#include <BADESCA.H>
#include "node.h"
#include "HtmlStyle.h"

using namespace DOM;

namespace Renderer
{
class HtmlStyle;

class RenderObject : public CBase
{
public:
	enum RenderType
	{
	RTAnonymousBlock = 0,
	RTBlock,
	RTInline
	};
public:
	RenderObject();
	virtual ~RenderObject();
	
public:
	RenderObject* FirstChild() const {return iFirstChild;}
	RenderObject* LastChild() const {return iLastChild;}
	RenderObject* NextSibling() const {return iNextSibling;}
	RenderObject* PreSibling() const {return iPreSibling;}
	RenderObject* ParentRenderObject() const {return iParent;}
	
	void SetFirstChild(RenderObject* obj) {iFirstChild = obj;}
	void SetLastChild(RenderObject* obj) {iLastChild = obj;}
	void SetNextSibling(RenderObject* obj) {iNextSibling = obj;}
	void SetPreSibling(RenderObject* obj) {iPreSibling = obj;}
	void SetParentRenderObject(RenderObject* obj) {iParent = obj;}
	
	HtmlStyle* GetHtmlStyle() {return &iHtmlStyle;}
	TInt GetRenderType() const {return iRenderType;}
	void SetRenderType(RenderType aType) {iRenderType = aType;}
	
	Node* BindNode() const {return iNode;}
	void SetBindNode(Node* aNode) {iNode = aNode;}
private:
	RenderObject* iFirstChild;
	RenderObject* iLastChild;
	RenderObject* iNextSibling;
	RenderObject* iPreSibling;
	RenderObject* iParent;
	TInt iChildNodeCount;
	
	HtmlStyle iHtmlStyle;
	Node* iNode;
	
	RenderType iRenderType;
public:
	static RenderObject* CreateRenderObjectL(Node* aNode,const TDesC& aDes);
	static void _parseMarginL(const TDesC& aDes,RenderObject* iRenderObj);
	static void _parsePaddingL(const TDesC& aDes,RenderObject* iRenderObj);
	static void _parseBorderL(const TDesC& aDes,RenderObject* iRenderObj);
	static void _parseWidth(const TDesC& aDes,RenderObject* iRenderObj);
	static void _parseHeight(const TDesC& aDes,RenderObject* iRenderObj);
	static void SetBordersL(const TDesC& aDes,HtmlStyle* aStyle);
	
public:
	virtual void AppendChildL(RenderObject* iObj);
	
private:
	void AppendChildSimply(RenderObject* iObj);
	RenderObject* CreateAnonymousObjectL();
};
}
#endif /*RENDEROBJECT_H_*/
